/** 
 * Task.java
 * @author Lex
 * 2007-9-16 ����11:35:29
 */
package org.lex.ftp.queue;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import org.lex.ftp.FTP;
import org.lex.net.ftp.FTPURL;
import org.lex.progress.Progress;


/**
 * Ŀǰֻ֧�����ػ����ϴ�����FXP��������Ƚϸ��ӣ���ʱ��֧��
 */
public abstract class Task implements TaskView {
	protected Progress.Status status = Progress.Status.NEW;
	protected final FTP app;
	protected final FTPURL url;

	public Task(FTP app) {
		this.app = app;
		this.url = app.getFTPExplorer().getFTPModel().getFTPURL();
	}

	public abstract void expandChildren();

	/**
	 * �����������/���<br>
	 * openInputStream()<b>����</b>Ҫ��openOutputStream()֮����ã���
	 * ΪopentOutputStream()
	 * ����Ҫ����FileExistRule�����ܻ�ֱ��Ӱ�쵽openInputStream().
	 */
	public abstract OutputStream openOutputStream() throws IOException;

	public abstract InputStream openInputStream() throws IOException;

	/**
	 * ���������Դ/Ŀ�������������������ʾ���������
	 */
	public FTPURL getURL() {
		return url;
	}

	public Progress.Status getStatus() {
		return this.status;
	}

	/**
	 * release resources. e.g.: close opened files,streams
	 */
	public void dispose() {
	}

	/*
	 * package private method
	 */
	void setStatus(Progress.Status status) {
		this.status = status;
	}
}
